home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-02-27 | 2.4 KB | 134 lines | [TEXT/CWIE] |
- /* SK8 © 1997 Apple Computer, Inc.
- This code is protected under the current SK8 License
- See http://sk8.research.apple.com/ for more information
- Apple Research Laboratories
- */
-
-
- import java.awt.*;
- import java.applet.Applet;
- import java.io.*;
-
-
- public class file extends Object
- {
- private File mFile;
- private String mFullName; //used when the file maybe does not exist on the disk.
-
- /////////////////////////////////
- //
- // Constructors
- //
- ///////////////////////////
-
- public file() {
- mFile = null;
- }
-
- public file(String path) {
- mFile = new File(path);
- }
-
-
-
- /////////////////////////////////
- //
- // data access
- //
- ///////////////////////////
-
- public File file() {
- return mFile;
- }
-
-
- /////////////////////////////////
- //
- // wrapper functions
- //
- ///////////////////////////
-
- public boolean delete () {
- if (mFile != null)
- return (mFile.delete());
- else
- return false;
- }
-
- public boolean isdirectory () {
- if (mFile != null)
- return (mFile.isDirectory());
- else
- return false;
- }
-
- public boolean fileexists () {
- if (mFile != null)
- return (mFile.exists());
- else
- return false;
- }
-
- public list filenames (){
- if ((mFile == null) || (! isdirectory()))
- return null;
- else {
- String[] strlist = mFile.list();
- list outCollection = new list();
- for (int i = strlist.length - 1; i >= 0; i--){
- outCollection.push(strlist[i]);
- }
- return outCollection;
- }
- }
-
-
- public String physicalname (){
- if ((mFile == null) || (! isdirectory()))
- return null;
- else {
- return mFile.getAbsolutePath();
- }
- }
- public String logicalname (){
- if ((mFile == null) || (! isdirectory()))
- return null;
- else {
- return mFile.getPath();
- }
- }
-
-
- public void setname (String s){
- if (mFile == null)
- mFullName = s;
- else
- mFile.renameTo(new File(s));
- }
-
- public void createfile (){
- //According to Java in a Nuthouse, files cant make themselves,
- //you need a FileOutputStream to do that.
- try {
- FileOutputStream fos = new FileOutputStream(mFullName);
- fos.close();
- } catch (Exception e){}
- }
-
- /////////////////////////////////
- //
- // utility functions
- //
- ///////////////////////////
-
- public String toString(){
- if (mFile == null)
- return new String("non-existant file");
- else {
- return mFile.toString();
- }
- }
-
-
- }
-